<?php
/**
 * Created by PhpStorm.
 * User: 小蛮哼哼哼
 * Email: 243194993@qq.com
 * Date: 2022/5/7
 * Time: 14:32
 * motto: 现在的努力是为了小时候吹过的牛逼！
 */

namespace app\timing\controller;

use app\BaseController;
use app\common\business\BusOrder;
use app\common\lib\Show;
use app\common\lib\Status;
use app\common\model\MallOrder;
use think\Exception;

class Timing extends BaseController
{
    /**
     * @return array|\think\response\Json
     */
    public function overdueOrder()
    {
        try {
            $result = (new MallOrder())->overdueOrder();
        } catch (\Exception $e) {
            return Show::json_show(Status::status_error, $e->getMessage());
        }
        if (!empty($result)) {
            $ids = array_column($result, 'id');
            try {
                $result = (new BusOrder())->CancelOrder($ids);
            } catch (\Exception $e) {
                return Show::json_show(Status::mini_error, $e->getMessage());
            }
            if ($result) {
                return Show::json_show(Status::status_normal, "处理成功");
            } else {
                return Show::json_show(Status::status_error, "订单商品查询失败");
            }
        } else {
            return Show::json_show(Status::status_error, "没有订单需要处理");
        }
    }
}